<!-- 搜索表单组件 -->
<div class="search-form-container mb-4">
    <form method="GET" class="row g-3">
        <!-- 保持其他查询参数 -->
        {% for key, value in request.args.items() %}
            {% if key not in ['page', 'search', 'status', 'role', 'campus_id'] %}
                <input type="hidden" name="{{ key }}" value="{{ value }}">
            {% endif %}
        {% endfor %}

        <!-- 关键词搜索 -->
        <div class="col-md-4">
            <div class="input-group">
                <span class="input-group-text"><i class="bi bi-search"></i></span>
                <input type="text" class="form-control" name="search"
                       placeholder="{{ search_placeholder or '输入关键词搜索...' }}"
                       value="{{ request.args.get('search', '') }}">
            </div>
        </div>

        <!-- 状态筛选 -->
        {% if show_status_filter %}
        <div class="col-md-2">
            <select class="form-select" name="status">
                <option value="">全部状态</option>
                {% for value, label in status_options %}
                    <option value="{{ value }}" {% if request.args.get('status') == value %}selected{% endif %}>
                        {{ label }}
                    </option>
                {% endfor %}
            </select>
        </div>
        {% endif %}

        <!-- 角色筛选 -->
        {% if show_role_filter %}
        <div class="col-md-2">
            <select class="form-select" name="role">
                <option value="">全部角色</option>
                {% for value, label in role_options %}
                    <option value="{{ value }}" {% if request.args.get('role') == value %}selected{% endif %}>
                        {{ label }}
                    </option>
                {% endfor %}
            </select>
        </div>
        {% endif %}

        <!-- 校区筛选 -->
        {% if show_campus_filter and campuses %}
        <div class="col-md-2">
            <select class="form-select" name="campus_id">
                <option value="">全部校区</option>
                {% for campus in campuses %}
                    <option value="{{ campus.id }}" {% if request.args.get('campus_id')|string == campus.id|string %}selected{% endif %}>
                        {{ campus.name }}
                    </option>
                {% endfor %}
            </select>
        </div>
        {% endif %}

        <!-- 搜索按钮 -->
        <div class="col-md-2">
            <button type="submit" class="btn btn-primary w-100">
                <i class="bi bi-search me-1"></i>搜索
            </button>
        </div>

        <!-- 重置按钮 -->
        <div class="col-md-2">
            <a href="{{ url_for(request.endpoint) }}" class="btn btn-outline-secondary w-100">
                <i class="bi bi-arrow-clockwise me-1"></i>重置
            </a>
        </div>
    </form>
</div>